package com.chz.SupermarketMS.dao;


import com.chz.SupermarketMS.dto.CommoditySD;
import com.chz.SupermarketMS.entities.SDetails;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SDetailsRepository extends CrudRepository<SDetails, Long> {

    @Override
    List<SDetails> findAll();

    @Query(nativeQuery = true,value = "SELECT s.sp_id as spId, cs.commodity_id as many, s.quantity, s.amount, s.price " +
            "FROM chz.sdetails as s left join chz.commodity_s_details as cs on s.sp_id = cs.s_details_id;"
    )
    List<CommoditySD> commoditySD();


//    SDetails findBySDetailsId(long theId);

    SDetails findBySpId(long theId);
}
